#! /bin/ksh
# IBM_PROLOG_BEGIN_TAG 
# This is an automatically generated prolog. 
#  
#  
#  
# Licensed Materials - Property of IBM 
#  
# (C) COPYRIGHT International Business Machines Corp. 2000,2004 
# All Rights Reserved 
#  
# US Government Users Restricted Rights - Use, duplication or 
# disclosure restricted by GSA ADP Schedule Contract with IBM Corp. 
#  
# IBM_PROLOG_END_TAG 
#*===========================================================================*/
#*                                                                           */
#* Module Name:  rmcd_start                                                  */
#*                                                                           */
#* Description:                                                              */
#*      Script to start the Resource Monitor & Control Daemon                */
#*                                                                           */
#* N.B. This command is intended to be executed by the RMC subsystem only !! */
#*                                                                           */
#*===========================================================================*/
#*   @(#)58   1.8   src/rsct/rmc/mcdaemon/rmcd_start.sh, mcdaemon, rsct_rzauh, rzauh0431a 10/31/03 16:17:24 

PATH=/usr/sbin/rsct/install/bin:/usr/sbin/rsct/bin:/usr/bin:/usr/sbin:/bin
export PATH

FIRST=/var/ct/first_start
FIRST_LOG=/var/ct/first.log
START_PORT_FILE=/var/ct/cfg/ctrmc.rpe
MSG_POLICY_FILE=/var/ct/cfg/ctrmc.msgp

REDHAT_RELFILE="/etc/redhat-release"
REDHAT_VERSION="^Red Hat Enterprise Linux .* release 3 (.*)$"

# sed string to extract subsystem state from "lssrc -s <subsys>" output
PARSE_SRC_STATE="-e1d;s/.* \([a-zA-Z0-9]*\)$/\1/"

# if the first start file is present, start the ctfirst script in the
# background.

if [[ -a $FIRST ]]
then
	ctfirst > $FIRST_LOG 2>&1 &
fi

# check if remote clients are to be accepted

if [[ -a $START_PORT_FILE ]]
then
	ROPT="-r"
else
	ROPT=
fi

# check of message authentication policy is to be set

MOPT=
if [[ -s $MSG_POLICY_FILE ]]
then
	POLICY=$(< $MSG_POLICY_FILE)
	case $POLICY in
		R ) MOPT="-m" ;;
		D ) MOPT="-M" ;;
	esac
fi

# check if running on RH EL release 3. If so, special processing

if [[ -f $REDHAT_RELFILE ]]
then
	grep "$REDHAT_VERSION" $REDHAT_RELFILE > /dev/null 2>&1
	if (($? == 0))
	then
		export LD_ASSUME_KERNEL=2.4.19
	fi
fi

# now start the RMC daemon in the current process so it is the child of the
# SRC subsystem daemon

exec /usr/sbin/rsct/bin/rmcd $ROPT $MOPT $@

